﻿@model PagedList.IPagedList<SIFIET.Models.Post>

@{
    ViewBag.Title = "Filtrado de Noticias";
}

<h1>Filtro de Noticias </h1> 

@if (Model.Count() != 0)
{

<table>
    <tr>
        <th width = "140"  >
            Usuario
        </th>
        <th width = "200" >
            Título
        </th>
        <th width = "400" >
            Resumen
        </th>
        <th width = "165">
            Fecha de Publicación
        </th>
        
        @if (ViewBag.CurrentFilter == "Mas Likes")
        {
            <th width = "165">
            Numero de Likes 
            </th> 
        }
        @if (ViewBag.CurrentFilter == "Mas Votadas")
        {
            <th width = "165">
            Votos Promedio
            </th>  
        }
        <th width = "130">
            Ir a Publicación
        </th>
      
    </tr>

    @foreach (var item in Model)
    {
        <tr>
            <td >
                @Html.DisplayFor(modelItem => item.User.FirstNames)
                @Html.DisplayFor(modelItem => item.User.LastNames)
            </td>
            <td style="text-align: justify;">
                @Html.DisplayFor(modelItem => item.Title)
            </td>
            <td style="text-align: justify;">
                @Html.DisplayFor(modelItem => item.Abstract)
            </td>
            <td style="text-align: center;">
                @Html.DisplayFor(modelItem => item.PublicationDate)
            </td>
            <td style="text-align: center;">
                @Html.DisplayFor(modelItem => item.Main)
            </td>
            <td style="text-align: center;">
             @Html.ActionLink("Ir", "ShowPost", new { id = item.Id }, htmlAttributes: new { @title = "IR", @class = "ebutton blue" }) 
            </td>
        </tr>
    }
</table>

<div>
    Página @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber)
    de @Model.PageCount
     
    @if (Model.HasPreviousPage)
    {
        @Html.ActionLink("<<", "GlobalFilter", new { page = 1 })
        @Html.Raw(" ");
        @Html.ActionLink("< Anterior", "GlobalFilter", new { page = Model.PageNumber - 1 })
    }
    else
    {
        @:<<
        @Html.Raw("   ");
        @:< Anterior
    }
     
    @if (Model.HasNextPage)
    {
        @Html.ActionLink("Siguiente>", "GlobalFilter", new { page = Model.PageNumber + 1 })
        @Html.Raw(" ");
        @Html.ActionLink(">>", "GlobalFilter", new { page = Model.PageCount })
    }
    else
    {
        @:Siguiente >
        @Html.Raw(" ")
        @:>>
    }
</div>

<script src="@Url.Content("~/Scripts/jquery-1.7.1.min.js")" 
type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/menu.js")" type="text/javascript"></script>
  
}

@if (Model.Count() == 0)
{
     <legend>No hay Coincidencias</legend>
}
<br/>


<p>    
    @Html.ActionLink("Regresar al Listado", "GlobalIndex", null, htmlAttributes: new { @class = "ebutton blue" })
</p>